package com.mz.mattress.admin.api.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mz.mattress.admin.api.req.PlanDateQueryReq;
import com.mz.mattress.admin.service.PlanDateService;
import com.mz.mattress.api.common.Constants;
import com.mz.mattress.api.common.Result;
import com.mz.mattress.api.entity.PlanDate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

@Slf4j
@RestController
@RequestMapping(Constants.ADMIN_PATH + "planDate")
public class PlanDateController {

    @Autowired
    private PlanDateService planDateService;

    @GetMapping("/listPage")
    public Result<IPage<PlanDate>> listPage(PlanDateQueryReq req) {
        return planDateService.listPage(req);
    }

    @GetMapping("/{id}")
    public Result<PlanDate> detail(@PathVariable Integer id) {
        return planDateService.getById(id);
    }

    @PostMapping
    public Result add(@RequestBody PlanDate planDate) {
        return planDateService.add(planDate);
    }

    @PutMapping
    public Result update(@RequestBody PlanDate planDate) {
        return planDateService.updateById(planDate);
    }

    @DeleteMapping
    public Result delete(@RequestBody Set<Integer> ids) {
        return planDateService.deleteByIds(ids);
    }

}
